package com.qf.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.pojo.DtsOrder;
import com.qf.vo.DayStatis;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 订单表 Mapper 接口
 * </p>
 *
 * @author zhaojian
 * @since 2021-05-12
 */
public interface DtsOrderMapper extends BaseMapper<DtsOrder> {



    //-- 日期和对应的订单总额, 订单笔数
    @Select("SELECT\n" +
            "\tcount( 1 ) cnts,\n" +
            "\tDATE_FORMAT( add_time, '%Y-%m-%d' ) dayStr,\n" +
            "\tsum( actual_price ) amts \n" +
            "FROM\n" +
            "\tdts_order \n" +
            "WHERE\n" +
            "\tDATE_FORMAT( DATE_ADD( NOW(), INTERVAL - 30 DAY ), '%Y-%m-%d' ) < DATE_FORMAT( add_time, '%Y-%m-%d' ) \n" +
            "GROUP BY\n" +
            "\tDATE_FORMAT( add_time, '%Y-%m-%d' )")
    List<DayStatis> findOrderDayStatisList();


    //-- 日期和对应的 订单笔数
    @Select("SELECT " +
            "\tcount( 1 ) cnts,\n" +
            "\tDATE_FORMAT( add_time, '%Y-%m-%d' ) dayStr " +
            "FROM\n" +
            "\tdts_order \n" +
            "WHERE\n" +
            "\tDATE_FORMAT( DATE_ADD( NOW(), INTERVAL - 30 DAY ), '%Y-%m-%d' ) < DATE_FORMAT( add_time, '%Y-%m-%d' ) \n" +
            "GROUP BY\n" +
            "\tDATE_FORMAT( add_time, '%Y-%m-%d' )")
    List<DayStatis> findOrderDayNumList();
}
